package cookinmaddy.database.spod;
import cookinmaddy.model.Unit;

class DBUnitManager extends php.db.Manager<DBUnit> 
{
	public function new() 
	{
		super(DBUnit);
	}
  
    override function make( c : DBUnit ) : Void 
	{
		c.value = new Unit();
		c.value.ID = c.uni_id;
		c.value.Name = c.uni_name;
		c.value.LongName = c.uni_longname;
	}
  
    override function unmake( c : DBUnit ) : Void 
	{
		c.uni_id = c.value.ID;
		c.uni_name = c.value.Name;
		c.uni_longname = c.value.LongName ;
	}	

	public function fromId(id : Int) : Unit
	{
		var val : DBUnit = DBUnit.manager.get(id);
		var ret : Unit = new Unit();
		return val.value;
	}		
	
	public function allUnits() : List<Unit>
	{
		var list : List<Unit> = new List<Unit>();
		var alldbunits = super.all();
		for (a in alldbunits)
		{
		  list.add(a.value);
		}
		return list;
	}
}